/**
 * @FileName: SysCodeValueUtils.java
 * @Author
 * @Description:
 * @Date 2017年2月14日 下午2:58:59
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.util;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.plugin.activerecord.Record;

import cn.hpclub.server.model.SysCodeType;
import cn.hpclub.server.model.SysCodeValue;

public class SysCodeValueUtils{
    private static final Logger logger               = LoggerFactory.getLogger(SysCodeValueUtils.class);

    public static final String  CCB_RE_RECHARGE      = "CCB_RE_RECHARGE_SWITCH";
    public static final String  CCB_SCHEDULED_REFUND = "CCB_REFUND_TIMER_SWITCH";
    public static final String  CCB_APP_REFUND       = "CCB_REFUND_APP_SWITCH";

    /**
     * @Title: getSysCodeValue
     * @Description:通过key获取配置小类的值
     * @param key
     * @return String
     */
    public static String getSysCodeValue(String key){
        String value = "";
        List<Record> list = SysCodeType.dao.getSysCodeTypeByCode(key);
        if(list.size() > 0){
            value = list.get(0).getStr(SysCodeValue.VALUE);
            // logger.debug("getSysCodeValue:" + value);
            // System.out.println("getSysCodeValue:" + value);
            return value;
        }

        return value;

    }

    public static boolean isSwitchOpen(String key){

        String value = getSysCodeValue(key);

        if("1".equals(value)){
            return true;
        }
        logger.debug("switch closed 1:" + key + "," + value);
        System.out.println("switch closed 2:" + key + "," + value);
        return false;
    }
}
